﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ATFCodeCS
{
	public partial class ATFCodeCS : Form
	{
		public ATFCodeCS()
		{
			InitializeComponent();
		}
		private FormSetingStore fs;

		private ReadWrite rw = new ReadWrite();
		private void hanhDong()
		{
			Text tx = new Text(txt1.Text);
			tx.DefaultFormat();
			Result ds = new Result(tx);
			ds.CF = rw.DSCF;
			ds.Format();
			txt1.Text = ds.ToStringFormat();
		}
		private void Form1_Load(object sender, EventArgs e)
		{
			fs = new FormSetingStore(@"SOFTWARE\ATFCODE\Form\1.0", this.Name);
			fs.ApplySetings(this);
			rw.readConfig("config.ini");

#if DEBUG

			rw.readData("data.txt");
			txt1.Text = rw.Data.ToString();
			hanhDong();
#else

#endif

#if (!DEBUG)
			txt1.Focus();
			txt1.Text = @"
		Past (Ctrl+V) code HTML vào đây
		F5 để chạy chương trình
		F6 Copy code và clipboard

		Sửa tập tin config.ini để có thêm định dạng.
		";
#endif

		}

		private void địnhDạngCodeToolStripMenuItem_Click(object sender, EventArgs e)
		{
			if (txt1.Text.Trim().Equals("About me"))
			{
				MessageBox.Show("n.k.r.r.l.\nn.k.r.r.l.@y.a.h.o.o...c.o.m...v.n.");
				return;
			}
			hanhDong();
		}

		private void passtToolStripMenuItem_Click(object sender, EventArgs e)
		{
			txt1.Text = Clipboard.GetText();
		}

		private void copyCodeVàoClipboardToolStripMenuItem_Click(object sender, EventArgs e)
		{
			Clipboard.SetText(txt1.Text);
		}

		private void ATFCodeCS_FormClosed(object sender, FormClosedEventArgs e)
		{
			fs.SaveSettings(this);
		}
	}
}